
"""
Legacy module for PKCS#1 v1.5 signatures.

:undocumented: __package__
"""

import types

from Crypto.Signature import pkcs1_15

def _pycrypto_verify(self, hash_object, signature):
    try:
        self._verify(hash_object, signature)
    except (ValueError, TypeError):
        return False
    return True

def new(rsa_key):
    pkcs1 = pkcs1_15.new(rsa_key)
    pkcs1._verify = pkcs1.verify
    # 将_pycrypto_verify方法绑定到pkcs1的对象上，就有个verify方法
    pkcs1.verify = types.MethodType(_pycrypto_verify, pkcs1)
    return pkcs1

